import { NextRequest, NextResponse } from 'next/server';
import { getLeaderboard } from '@/lib/leaderboard';

export async function GET(request: NextRequest) {
  try {
    const categoryId = request.nextUrl.searchParams.get('categoryId') || null;
    const leaderboard = getLeaderboard(categoryId);
    
    return NextResponse.json({ success: true, leaderboard });
  } catch (error) {
    return NextResponse.json(
      { success: false, message: '获取排行榜失败' },
      { status: 500 }
    );
  }
}

